package com.zshan.clinic.admin.mapper.medical;


import com.zshan.clinic.admin.entity.vo.*;
import com.zshan.clinic.database.model.OrderDeliveryDetail;
import com.zshan.clinic.database.model.OrderDispenseRx;
import com.zshan.clinic.mybatis.SuperMapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;

/**
 * @author lichen
 */
public interface SpecOrderDispenseMapper extends SuperMapper {

    /**
     * 查询患者发药数
     * @param clinicId
     * @param patientId
     * @param visitDate
     * @return
     */
    Long getPatientDeliveryCount(@Param("clinicId") Long clinicId,
                                 @Param("patientId") Long patientId,
                                 @Param("visitDate") LocalDate visitDate);

    /**
     * 查询患者发药记录
     * @param clinicId
     * @param patientId
     * @param visitDate
     * @param offset
     * @param limit
     * @return
     */
    List<OrderDeliveryPatientVo> getPatientDeliveryList(@Param("clinicId") Long clinicId,
                                                        @Param("patientId") Long patientId,
                                                        @Param("visitDate") LocalDate visitDate,
                                                        @Param("offset") Integer offset,
                                                        @Param("limit") Integer limit);

    /**
     * 批量添加配药单处方
     * @param orderDispenseRxList
     */
    void addOrderDispenseRxBatch(@Param("rxList") List<OrderDispenseRx> orderDispenseRxList);

    /**
     * 批量添加发药单处方
     * @param deliveryDetailList
     */
    void addOrderDeliveryDetailBatch(@Param("detailList") List<OrderDeliveryDetail> deliveryDetailList);

    /**
     * 查询配药单列表
     * @param clinicId
     * @param patientName
     * @param visitDate
     * @param offset
     * @param limit
     * @return
     */
    List<OrderDispensePageVo> getDispenseList(@Param("clinicId") Long clinicId,
                                              @Param("patientName") String patientName,
                                              @Param("visitDate") LocalDate visitDate,
                                              @Param("offset") Integer offset,
                                              @Param("limit") Integer limit);
    /**
     * 查询配药单详情
     * @param clinicId
     * @param orderId
     * @return
     */
    OrderDispenseDetailVo getDispenseDetail(@Param("clinicId") Long clinicId,
                                            @Param("orderId") Long orderId);

    /**
     * 批量修改配药表处方数据
     * @param dispenseRxList
     */
    void updateOrderDispenseRxBatch(@Param("rxList") List<OrderDispenseRx> dispenseRxList);

    /**
     * 批量修改发药表数据
     * @param deliveryDetailList
     */
    void updateOrderDeliveryDetailBatch(@Param("detailList") List<OrderDeliveryDetail> deliveryDetailList);

    /**
     * 查询发药单详情
     * @param clinicId
     * @param orderId
     * @return
     */
    OrderDeliveryDetailVo getDeliveryDetail(@Param("clinicId") Long clinicId,
                                            @Param("orderId") Long orderId);

    /**
     * 查询发药单列表
     * @param clinicId
     * @param patientName
     * @param visitDate
     * @param offset
     * @param limit
     * @return
     */
    List<OrderDeliveryPageVo> getDeliveryList(@Param("clinicId") Long clinicId,
                                              @Param("patientName") String patientName,
                                              @Param("visitDate") LocalDate visitDate,
                                              @Param("offset") Integer offset,
                                              @Param("limit") Integer limit);

    /**
     * 查询用户配药历史
     * @param clinicId
     * @param patientId
     * @param deliveryStatus
     * @param offset
     * @param limit
     * @return
     */
    List<OrderDeliveryDetailVo> getDeliveryDetailList(@Param("clinicId") Long clinicId,
                                                      @Param("patientId") Long patientId,
                                                      @Param("deliveryStatus") String deliveryStatus,
                                                      @Param("offset") Integer offset,
                                                      @Param("limit") Integer limit);

    /**
     * 查询诊所今日药品待发数
     * @param clinicId
     * @param visitDate
     * @return
     */
    DispenseWaitingVo getWaitingCount(@Param("clinicId") Long clinicId,
                                      @Param("visitDate") LocalDate visitDate);

}
